﻿
                                  <div class="box border primary">
											<div class="box-title">
												<h4><i class="fa fa-bars"></i>Form controls</h4>
												<div class="tools hidden-xs">
													<a href="#box-config" data-toggle="modal" class="config">
														<i class="fa fa-cog"></i>
													</a>
													<a href="javascript:;" class="reload">
														<i class="fa fa-refresh"></i>
													</a>
													<a href="javascript:;" class="collapse">
														<i class="fa fa-chevron-up"></i>
													</a>
													<a href="javascript:;" class="remove">
														<i class="fa fa-times"></i>
													</a>
												</div>
											</div>
											<div class="box-body big">
												<h3 class="form-title">角色添加</h3>
												<form method="post" action="" class="form-horizontal" role="form" enctype="multipart/form-data">
												  <div class="form-group">
													<label class="col-sm-3 control-label">角色名称</label>
													<div class="col-sm-2">
													  <input name="name" class="form-control" placeholder="" type="text">
													</div>
												  </div>

											<div class="box solid white">
												<div class="box-title">
													<h4><i class="fa fa-bars"></i>权限列表</h4>
													<div class="tools">
														<a href="#box-config" data-toggle="modal" class="config">
															<i class="fa fa-cog"></i>
														</a>
														<a href="javascript:;" class="reload">
															<i class="fa fa-refresh"></i>
														</a>
														<a href="javascript:;" class="collapse">
															<i class="fa fa-chevron-up"></i>
														</a>
														<a href="javascript:;" class="remove">
															<i class="fa fa-times"></i>
														</a>
													</div>
											</div>
<?php foreach($date as $k=>$v): ?>											
<div class="box-body">
		<div class="checkbox">
		
		<input id="all" name="author_id[]" value="<?php echo $v['id']?>" pid='0' type="checkbox"><?php echo $v['name']?>
		
		</div>
		<div class="form-group">
		<div class="col-sm-9">
		<?php foreach($v['ch'] as $k1=>$v1): ?>
		<label class="checkbox-inline">
		<input id="ch" name='author_id[]' id="inlineCheckbox1" value="<?php echo $v1['id']?>" type="checkbox"><?php echo $v1['name']?>
		</label>
		<?php endforeach; ?>
		</div>
		</div>

</div>
<?php endforeach; ?>	



									
												</div>
											</div>
	  
                                                <div class="col-sm-offset-3 col-sm-13">
                                                 <button type="submit" class="btn btn-success">提交</button>
													</div>
												 </form>
											</div>
										</div>
<script src="public/admin/js/jquery/jquery-2.0.3.min.js"></script>

<script type="text/javascript">
$(function(){
		$('input[id=all]').click(function(){
			if($(this).prop('checked')){
					$(this).parent().siblings('.form-group').find('input').prop('checked',true);
			}else{
					$(this).parent().siblings('.form-group').find('input').prop('checked',false);
			}
			
		});

		$('input[id=ch]').click(function(){
			var len=$(this).parent().parent().find('input:checked').length;
			
			if($(this).prop('checked')){
				$(this).parent().parent().parent().siblings('.checkbox').find('input').prop('checked',true);
			}else if(len<1){
				$(this).parent().parent().parent().siblings('.checkbox').find('input').prop('checked',false);
			}
			
		});
})
</script>
